#include<my_header.h>

#include"head.h"
#include"doRegiseterOrLogin.h"
#include"initTcp.h"

char *getKey(HashMap *map, char *key);

int main()
{
	client_state_t client_state;
	memset(&client_state, 0, sizeof(client_state));

	client_state._map = parameterMap();
	printf("ip:%s\n", getKey(client_state._map, "ip"));
	printf("port:%s\n", getKey(client_state._map, "port"));
	strcpy(client_state._keepPath, "/");

	// 获取 IP 和端口
	char *ip = getKey(client_state._map, "ip");
	char *port = getKey(client_state._map, "port");

	// 初始化 TCP 连接
	initTcp(&client_state._netfd, ip, port);

	while (1) {
		// 查看用户登录状态
		if (client_state._isLogin == 0) {
            //开始登录
			doRegiseterOrLogin(&client_state);
		} else {
            //登录成功
		    doCommand(&client_state);
		}
	}

	return 0;
}
